package com.biz.hunter.dao;

import org.springframework.stereotype.Repository;

import com.biz.hunter.db.entity.OrderPlan;
import com.biz.hunter.dbutil.BaseDAO;

@Repository
public class OrderPlanDAO {
	private static final String SQL_GET_ID = "select * from tb_order_plan where id = ?";
	private static final String SQL_SAVE = "INSERT INTO tb_order_plan(openid, orderId,employeeId,hunterId,ordescId,file,"
			+ "remarkImp,remarkOnce,remarkDev,remarkGoal,createtime,updatetime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
	private static final String SQL_GET_ORDERID="select * from tb_order_plan where orderId=?";
	
	public OrderPlan getPlanById(long Id) {
		return BaseDAO.queryForObject(OrderPlan.class, SQL_GET_ID, Id);
	}

	public OrderPlan getPlanByOrderId(long orderId){
		return BaseDAO.queryForObject(OrderPlan.class, SQL_GET_ORDERID, orderId);
	}
	
	public long saveOrderPlan(OrderPlan plan) {
		if (plan == null) {
			return -1;
		}

		Long result = BaseDAO.save(SQL_SAVE, plan.getOpenid(), plan.getOrderId(),
				plan.getEmployeeId(),plan.getHunterId(),plan.getOrdescId(),
				plan.getFile(),plan.getRemarkImp(),plan.getRemarkOnce(),plan.getRemarkDev(),plan.getRemarkGoal(),
				plan.getCreatetime(),plan.getUpdatetime());
		if (result != null) {
			return result.longValue();
		}
		return -1;
	}
	


}
